package com.wao.cms.service.mapper;

import com.wao.cms.domain.*;
import com.wao.cms.service.dto.PropertyValueDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity PropertyValue and its DTO PropertyValueDTO.
 */
@Mapper(componentModel = "spring", uses = {PageMapper.class, TemplatePropertyMapper.class, MaterialMapper.class, })
public interface PropertyValueMapper extends EntityMapper <PropertyValueDTO, PropertyValue> {

    @Mapping(source = "page.id", target = "pageId")
    @Mapping(source = "page.name", target = "pageName")

    @Mapping(source = "property.id", target = "propertyId")
    @Mapping(source = "property.name", target = "propertyName")

    @Mapping(source = "material.id", target = "materialId")
    @Mapping(source = "material.name", target = "materialName")
    PropertyValueDTO toDto(PropertyValue propertyValue); 

    @Mapping(source = "pageId", target = "page")

    @Mapping(source = "propertyId", target = "property")

    @Mapping(source = "materialId", target = "material")
    PropertyValue toEntity(PropertyValueDTO propertyValueDTO); 
    default PropertyValue fromId(Long id) {
        if (id == null) {
            return null;
        }
        PropertyValue propertyValue = new PropertyValue();
        propertyValue.setId(id);
        return propertyValue;
    }
}
